<!-- 资质证书 -->
<template>
  <div class="">
    <a-form-model layout="inline">
      <a-row :gutter="24">
        <a-col :md="8" :sm="24">
          <a-form-model-item label="供应商主营品类">
            <ASelectList v-model="supplierMainCategory" :isHasDict="false" :disabled="!isEdit" :defaultOption="supplierMainCategoryOption" @change="supplierMainCategoryChange" />
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
    <div class="mt-10">
      <a-table
        ref="table"
        rowKey="id"
        size="middle"
        bordered
        :loading="loading"
        :columns="columns"
        :dataSource="dataSource"
        :scroll="{ x: 1, y: 400 }"
        :pagination="false">
        <span slot="date" slot-scope="text">{{ text | DateFormat }}</span>
        <span slot="isRequired" slot-scope="text, record">
          <span v-show="record.isRequired === '1'">是</span>
          <span v-show="record.isRequired === '0'">否</span>
        </span>
        <template slot="action" slot-scope="text, record">
          <span v-if="isEdit" class="cus-text" pointer @click="onUpload(record)">上传</span>
          <span v-if="!isEdit" class="cus-text" pointer @click="onCheck(record)">查看</span>
          <span class="cus-text" pointer @click="onDownload(record)">下载</span>
        </template>
      </a-table>
    </div>
  </div>
</template>

<script>
import ListPageMixin from '@/mixins/ListPageMixin.js';

export default {
  name: 'QualificationCertificate',
  mixins: [ ListPageMixin ],
  props: {
    isEdit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      supplierMainCategory: '1',
      supplierMainCategoryOption: [
        { label: '传感器品类', value: '1' },
        { label: '轮胎品类', value: '2' },
      ],
      dataSource: [],
      originalDataSource: [
        {
          fileType: '营业执照',
          isRequired: '1',
          fileName: 'PCN协议001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '税务登记证',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '组织机构代码证',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '安全生产许可证',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '工业产品生产许可证',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '进出口资质',
          isRequired: '0',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: 'ISO 9001质量管理体系认证',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '行业专项认证',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '检测报告',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '型式试验证书',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '专利证书',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
        {
          fileType: '技术授权协议',
          isRequired: '1',
          fileName: '无有害物001.docx',
          fileFormat: 'docx',
          fileSize: '1MB',
          startTime: '2025-1-10 12:00:00',
          endTime: '2025-1-10 12:00:00',
          uploadTime: '2025-1-10 12:00:00',
          uploadPerson: '杨先生'
        },
      ],
      columns: [
        { title: '序号', width: 50, customRender: (text, record, index) => `${index + 1}`, align: 'center', },
        { title: '文件类型', dataIndex: 'fileType', width: 220, ellipsis: true },
        { title: '是否必填', dataIndex: 'isRequired', width: 100, scopedSlots: { customRender: 'isRequired' }, ellipsis: true },
        { title: '文件名称', dataIndex: 'fileName', width: 220, ellipsis: true },
        { title: '文件格式', dataIndex: 'fileFormat', width: 100, ellipsis: true },
        { title: '文件大小', dataIndex: 'fileSize', width: 100, ellipsis: true },
        { title: '有效期开始时间', dataIndex: 'startTime', width: 150, scopedSlots: { customRender: 'date' }, ellipsis: true },
        { title: '有效期结束时间', dataIndex: 'endTime', width: 150, scopedSlots: { customRender: 'date' }, ellipsis: true },
        { title: '上传时间', dataIndex: 'uploadTime', width: 150, scopedSlots: { customRender: 'date' }, ellipsis: true },
        { title: '上传人', dataIndex: 'uploadPerson', width: 100, ellipsis: true },
        { title: '文件', dataIndex: 'action', width: 120, align: 'center', fixed: 'right', scopedSlots: { customRender: 'action' } }
      ]
    };
  },
  mounted() {
    this.handleSearch();
  },
  methods: {
    handleSearch() {
      this.loading = true;
      setTimeout(() => {
        this.loading = false;
        this.onSelectClear();
        this.dataSource = this.originalDataSource
      }, 100)
    },
    supplierMainCategoryChange() {
      this.handleSearch();
    },
    onCheck() {

    },
    onUpload() {

    },
    onDownload() {

    },
  }
}
</script>

<style lang="less" scoped>
.ant-table {
}
</style>